﻿using Hinacom.Scheduler.Service;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Topshelf;
using Hinacom.Scheduler.Hosts.WinService.Configuration;

namespace Hinacom.Scheduler.Hosts.WinService
{
    class Program
    {
        static void Main(string[] args)
        {
            Directory.SetCurrentDirectory(System.AppDomain.CurrentDomain.BaseDirectory);

            var config = SchedulerWinServiceConfiguration.Current;

            HostFactory.Run(x =>
            {
                x.RunAsLocalSystem();

                x.SetDescription(config.Description);
                x.SetDisplayName(config.DisplayName);
                x.SetServiceName(config.ServiceName);
                
                x.Service(factory =>
                {
                    SchedulerServiceHost svc = new SchedulerServiceHost();
                    return svc;
                });
            });
        }
    }
}
